/**
 * 
 */
package org.acsis.covoiturage.frontend.validators;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Abdellah
 *
 */
public class AjoutValidator {

	static public boolean dateNotValid(String date){
		Pattern pattern = Pattern.compile("^((0[1-9]|1\\d|2[0-8])/(0\\d|1[012])/(1[6-9]|[2-9]\\d)\\d{2}|(29|30)/(0[13-9]|1[012])/(1[6-9]|[2-9]\\d)\\d{2}|31/(0[13578]|1[02])/(1[6-9]|[2-9]\\d)\\d{2}|29/02/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))$");
		Matcher matcher = pattern.matcher(date);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	static public boolean heureNotValid(String heure){
		Pattern pattern = Pattern.compile("(([0-1]){1,}([0-9]{1,})|(2[0-3]))(:)([0-5]{1}[0-9]{1})");
		Matcher matcher = pattern.matcher(heure);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	static public boolean prixPlaceNotValid(String prixPlace){
		Pattern pattern = Pattern.compile("[0-9]");
		Matcher matcher = pattern.matcher(prixPlace);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	static public boolean nbrPlacesNotValid(String nbrPlaces){
		Pattern pattern = Pattern.compile("[0-9]");
		Matcher matcher = pattern.matcher(nbrPlaces);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	static public boolean villeDepartNotValid(String villeDepart){
		Pattern pattern = Pattern.compile("^[A-Za-z0-9_-]{3,16}$");
		Matcher matcher = pattern.matcher(villeDepart);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	static public boolean villeArriveNotValid(String villeArrive){
		Pattern pattern = Pattern.compile("^[A-Za-z0-9_-]{3,16}$");
		Matcher matcher = pattern.matcher(villeArrive);
		if (matcher.matches()) {
			return false;
		} else {
			return true;
		}
	}
	
}
